/**
 * Created by tangting on 2017/12/5.
 */

import Vue from 'vue';
import tpl from './tpl.html';
import './style.scss';
import commonService from '../../../common/commonService';
import symbolConfig from '../../../common/symbolConfig';
import format from '../../../common/format';
import CONFIG from './config'

import Loading from '../../../../grsc-base/component/Loading.vue';
import NoData from '../../../../grsc-base/component/NoData.vue';

import filter from '../../../../grsc-base/util/filter';
import mathtool from '../../../../grsc-base/util/mathtool';
import lang from './lang';
import service from './service';
const SORT_UP = 'UP';
const SORT_DOWN = 'DOWN';

export default Vue.extend({
	name: "news",
	template: tpl,
	components: {
		Loading,
		NoData
	},
	data() {
		return {
			symbolConfig: symbolConfig,

			lang: lang[this.$i18n.locale],
			isLoading: true,
			filter: filter,
			list: "",
			hasNotice: true,

		}
	},
	created() {
		this.loadNews();
	},
	mounted() {
		
	},
	methods: {
		loadNews() {
			let params = {
                pageNo: 1,
                pageSize: 4,
            };
			commonService.getNotice(params).done((rep)=> {
                if (rep.code === window.CODE.SUCCESS) {
                    if (rep.data.list !== null && rep.data.list.length > 0) {
						for(let i=0;i<4;i++) {
							this.list.concat(rep.data.list[i]);
						}
                        this.list = rep.data.list; 
                    } else {
                        this.hasNotice = false;
                    }
                } else {
                    window.error(rep.msg);
                }
            }).fail((rep)=> {
                window.error(rep.msg);
            });
		},
		goNews(id) {
			window.location.href = "/notice.html#/?id="+ id;
		},
		goNewlist() {
			window.location.href = "/notice.html";
		}
	}
});